{extend name="main"}

{block name="button"}
<!--{if auth('options_wxapp')}-->
<button data-modal="{:url('options_wxapp')}" data-width="600px" data-title="绑定小程序" class='layui-btn layui-btn-sm layui-btn-primary'>绑定小程序</button>
<!--{/if}-->
<!--{if auth('options_jsonrpc')}-->
<button data-modal="{:url('options_jsonrpc')}" data-width="600px" data-title="开放平台接口配置" class='layui-btn layui-btn-sm layui-btn-primary'>开放平台接口</button>
<!--{/if}-->
<!--{if auth("options_test")}-->
<button data-modal="{:url('options_test')}" data-width="600px" data-title="微信授权测试（ 扫码 ）" class='layui-btn layui-btn-sm layui-btn-primary'>微信授权测试</button>
<!--{/if}-->
{/block}

{block name="content"}
<div class="think-box-shadow layui-form">
    <div style="margin-left:99px;max-width:750px">
        {foreach ['api'=>lang('微信公众平台直接模式'),'thr'=>lang('微信开放平台授权模式')] as $k=>$v}
        <input type="radio" data-wechat-type="{$k}" name="wechat.type" value="{$k}" title="{$v}" lay-filter="wechat_type">
        {/foreach}
        <div class="help-block">{:lang('请选择微信对接方式，其中微信开放平台授权模式需要微信开放平台支持，还需要搭建第三方服务平台托管系统！')}</div>
    </div>
</div>
<div class="think-box-shadow margin-top-15">
    <div class="padding-top-20" style="max-width:850px">
        <div class="layui-anim layui-anim-fadein" data-type="api">{include file='config/options_form_api'}</div>
        <div class="layui-anim layui-anim-fadein" data-type="thr">{include file='config/options_form_thr'}</div>
    </div>
</div>
{/block}

{block name='script'}
<script>
    $(function () {
        window.form.on('radio(wechat_type)', apply);
        apply({value: '{:sysconf("wechat.type")}' || 'api'});

        function apply(data) {
            this.$active = $("[data-wechat-type='" + data.value + "']").trigger('click');
            if (this.$active.size() < 1) $("[data-wechat-type]:first").trigger('click');
            $('[data-type="' + data.value + '"]').show().siblings('[data-type]').hide();
        }
    });
</script>
{/block}
